From 69e0d9f7855cca3ef4272a9875229e22ed9c1cbc Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Mon, 4 Sep 2017 20:31:01 -0700 Subject: [PATCH] get doctests to pass --- src/cargo/ops/cargo_rustc/context.rs | 36 +++++++++++++++++++++------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index ffce9680b..1f02d07a2 100755 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -25,7 +25,7 @@ use super::layout::Layout; use super::links::Links; use super::{Kind, Compilation, BuildConfig}; -#[derive(Clone, Copy, Eq, PartialEq, Hash)] +#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] pub struct Unit<'a> { pub pkg: &'a Package, pub target: &'a Target, @@ -483,14 +483,30 @@ impl<'a, 'cfg> Context<'a, 'cfg> { // when changing feature sets each lib is separately cached. self.resolve.features_sorted(unit.pkg.package_id()).hash(&mut hasher); - if let Ok(dep_units) = self.dep_targets(&unit) { - let mut dep_metadatas = dep_units.into_iter().map(|dep_unit| { - self.target_metadata(&dep_unit) + // Mix in the target-metadata of all the dependencies of this target + { + let id = unit.pkg.package_id(); + let deps = self.resolve.deps(id); + let mut deps = deps.filter_map(|id| { + match self.get_package(id) { + Ok(pkg) => { + pkg.targets().iter().find(|t| t.is_lib()).map(|t| { + let unit = Unit { + pkg: pkg, + target: t, + profile: self.lib_or_check_profile(unit, t), + kind: unit.kind.for_target(t), + }; + Some(self.target_metadata(&unit)) + }) + } + Err(_) => None + } }).collect::>(); - dep_metadatas.sort(); - for metadata in dep_metadatas { - metadata.hash(&mut hasher); - } + + debug!("Mixing in units {:?} to {:?}:{:?}", deps.len(), unit.target.name(), unit.target.kind()); + deps.sort(); + deps.hash(&mut hasher); } // Throw in the profile we're compiling with. This helps caching @@ -518,7 +534,9 @@ impl<'a, 'cfg> Context<'a, 'cfg> { channel.hash(&mut hasher); } - Some(Metadata(hasher.finish())) + let x = Metadata(hasher.finish()); + debug!("Produced hash {} for {:?}:{:?}", x, unit.target.name(), unit.target.kind()); + Some(x) } /// Returns the file stem for a given target/profile combo (with metadata) -- 2.30.2